<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>Introduction_to_Algorithms: IntroductionToAlgorithm::TreeAlgorithm::SearchTree&lt; NodeType &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Introduction_to_Algorithms
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">IntroductionToAlgorithm::TreeAlgorithm::SearchTree&lt; NodeType &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>SearchTree：二叉搜索树，算法导论12章  
 <a href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="searchtree_8h_source.html">searchtree.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for IntroductionToAlgorithm::TreeAlgorithm::SearchTree&lt; NodeType &gt;:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.png" usemap="#IntroductionToAlgorithm::TreeAlgorithm::SearchTree&lt; NodeType &gt;_map" alt=""/>
  <map id="IntroductionToAlgorithm::TreeAlgorithm::SearchTree&lt; NodeType &gt;_map" name="IntroductionToAlgorithm::TreeAlgorithm::SearchTree&lt; NodeType &gt;_map">
<area href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html" alt="IntroductionToAlgorithm::TreeAlgorithm::BinaryTree&lt; NodeType &gt;" shape="rect" coords="0,0,385,24"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a0a9b2de6326042f2a1fa8a3a0def67ab"><td class="memItemLeft" align="right" valign="top">typedef NodeType::KeyType&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a0a9b2de6326042f2a1fa8a3a0def67ab">T</a></td></tr>
<tr class="separator:a0a9b2de6326042f2a1fa8a3a0def67ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_types_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td colspan="2" onclick="javascript:toggleInherit('pub_types_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree')"><img src="closed.png" alt="-"/>&#160;Public Types inherited from <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html">IntroductionToAlgorithm::TreeAlgorithm::BinaryTree&lt; NodeType &gt;</a></td></tr>
<tr class="memitem:a9a441f3f41c5b69758204ba60fe02010 inherit pub_types_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a></td></tr>
<tr class="separator:a9a441f3f41c5b69758204ba60fe02010 inherit pub_types_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af231d881ec1d08492b2b5b5638e5e373 inherit pub_types_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memItemLeft" align="right" valign="top">typedef NodeType::KeyType&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#af231d881ec1d08492b2b5b5638e5e373">KeyType</a></td></tr>
<tr class="separator:af231d881ec1d08492b2b5b5638e5e373 inherit pub_types_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:affaf44d28dc2180f93669cb8d6c09c84"><td class="memItemLeft" align="right" valign="top">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#affaf44d28dc2180f93669cb8d6c09c84">search</a> (const <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a0a9b2de6326042f2a1fa8a3a0def67ab">T</a> &amp;value, std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt; node=std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;())</td></tr>
<tr class="memdesc:affaf44d28dc2180f93669cb8d6c09c84"><td class="mdescLeft">&#160;</td><td class="mdescRight">search:在二叉搜索树中搜索指定内容的节点。  <a href="#affaf44d28dc2180f93669cb8d6c09c84">More...</a><br /></td></tr>
<tr class="separator:affaf44d28dc2180f93669cb8d6c09c84"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af0bb418896808f72bb1edee55d238d55"><td class="memItemLeft" align="right" valign="top">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#af0bb418896808f72bb1edee55d238d55">min</a> (std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt; node)</td></tr>
<tr class="memdesc:af0bb418896808f72bb1edee55d238d55"><td class="mdescLeft">&#160;</td><td class="mdescRight">min:在二叉搜索树中最小值的节点。  <a href="#af0bb418896808f72bb1edee55d238d55">More...</a><br /></td></tr>
<tr class="separator:af0bb418896808f72bb1edee55d238d55"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2dfe32f3914b03ccdb22f88f24a6afdd"><td class="memItemLeft" align="right" valign="top">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a2dfe32f3914b03ccdb22f88f24a6afdd">max</a> (std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt; node)</td></tr>
<tr class="memdesc:a2dfe32f3914b03ccdb22f88f24a6afdd"><td class="mdescLeft">&#160;</td><td class="mdescRight">max:在二叉搜索树中最大值的节点。  <a href="#a2dfe32f3914b03ccdb22f88f24a6afdd">More...</a><br /></td></tr>
<tr class="separator:a2dfe32f3914b03ccdb22f88f24a6afdd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9d53e1f0b130263f2974dced515aa1f1"><td class="memItemLeft" align="right" valign="top">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a9d53e1f0b130263f2974dced515aa1f1">successor</a> (std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt; node)</td></tr>
<tr class="memdesc:a9d53e1f0b130263f2974dced515aa1f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">successor:二叉搜索树指定节点的后继节点。  <a href="#a9d53e1f0b130263f2974dced515aa1f1">More...</a><br /></td></tr>
<tr class="separator:a9d53e1f0b130263f2974dced515aa1f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0e767d97590d19c97d595708d4419fe1"><td class="memItemLeft" align="right" valign="top">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a0e767d97590d19c97d595708d4419fe1">predecesor</a> (std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt; node)</td></tr>
<tr class="memdesc:a0e767d97590d19c97d595708d4419fe1"><td class="mdescLeft">&#160;</td><td class="mdescRight">predecesor:二叉搜索树指定节点的前驱。  <a href="#a0e767d97590d19c97d595708d4419fe1">More...</a><br /></td></tr>
<tr class="separator:a0e767d97590d19c97d595708d4419fe1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a83724f0079d16419d4cceba74602cee1"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a83724f0079d16419d4cceba74602cee1">insert</a> (std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt; node)</td></tr>
<tr class="memdesc:a83724f0079d16419d4cceba74602cee1"><td class="mdescLeft">&#160;</td><td class="mdescRight">insert:向二叉搜索树中插入节点。  <a href="#a83724f0079d16419d4cceba74602cee1">More...</a><br /></td></tr>
<tr class="separator:a83724f0079d16419d4cceba74602cee1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3b59a0c117766590f7f01027ad0fbfff"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a3b59a0c117766590f7f01027ad0fbfff">remove</a> (std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt; node)</td></tr>
<tr class="memdesc:a3b59a0c117766590f7f01027ad0fbfff"><td class="mdescLeft">&#160;</td><td class="mdescRight">remove:从二叉搜索树中删除节点。  <a href="#a3b59a0c117766590f7f01027ad0fbfff">More...</a><br /></td></tr>
<tr class="separator:a3b59a0c117766590f7f01027ad0fbfff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html">IntroductionToAlgorithm::TreeAlgorithm::BinaryTree&lt; NodeType &gt;</a></td></tr>
<tr class="memitem:adc9b1c18fd12ab56de09e92005848abf inherit pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#adc9b1c18fd12ab56de09e92005848abf">BinaryTree</a> ()</td></tr>
<tr class="memdesc:adc9b1c18fd12ab56de09e92005848abf inherit pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="mdescLeft">&#160;</td><td class="mdescRight">默认函数  <a href="#adc9b1c18fd12ab56de09e92005848abf">More...</a><br /></td></tr>
<tr class="separator:adc9b1c18fd12ab56de09e92005848abf inherit pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a96fa515f1c3b4176a03c37b8ea582339 inherit pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a96fa515f1c3b4176a03c37b8ea582339">to_xml</a> ()</td></tr>
<tr class="memdesc:a96fa515f1c3b4176a03c37b8ea582339 inherit pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="mdescLeft">&#160;</td><td class="mdescRight">to_xml:返回本树的<code>xml</code>描述。  <a href="#a96fa515f1c3b4176a03c37b8ea582339">More...</a><br /></td></tr>
<tr class="separator:a96fa515f1c3b4176a03c37b8ea582339 inherit pub_methods_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pub_attribs_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td colspan="2" onclick="javascript:toggleInherit('pub_attribs_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree')"><img src="closed.png" alt="-"/>&#160;Public Attributes inherited from <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html">IntroductionToAlgorithm::TreeAlgorithm::BinaryTree&lt; NodeType &gt;</a></td></tr>
<tr class="memitem:aa0d43af70ef50ff59740dced2e832074 inherit pub_attribs_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memItemLeft" align="right" valign="top">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#aa0d43af70ef50ff59740dced2e832074">root</a></td></tr>
<tr class="separator:aa0d43af70ef50ff59740dced2e832074 inherit pub_attribs_struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename NodeType&gt;<br />
class IntroductionToAlgorithm::TreeAlgorithm::SearchTree&lt; NodeType &gt;</h3>

<p>SearchTree：二叉搜索树，算法导论12章 </p>
<p>二叉搜索树是一种特殊的二叉树。在二叉树中的任何一个节点，该节点的左子节点值小于它；该节点的右子节点值大于它。</p>
<blockquote class="doxtable">
<p>这里节点值指的是节点存储的数据的值</p>
</blockquote>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00033">33</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a class="anchor" id="a0a9b2de6326042f2a1fa8a3a0def67ab"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">typedef NodeType::KeyType <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::<a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a0a9b2de6326042f2a1fa8a3a0def67ab">T</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>树的节点存储数据的类型 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00036">36</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a83724f0079d16419d4cceba74602cee1"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::insert </td>
          <td>(</td>
          <td class="paramtype">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td>
          <td class="paramname"><em>node</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>insert:向二叉搜索树中插入节点。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">node:要插入的节点</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>: void</dd></dl>
<p>给定新节点<code>node</code>，将该节点插入到二叉搜索树中。</p>
<p>算法：遍历二叉搜索树，若当前节点的值大于<code>node</code>的值，则向左侧遍历；若当前节点值小于<code>node</code>的值，则向右侧遍历。直到碰到<code>nullptr</code>则挂载该节点</p>
<p>算法时间复杂度O(h)，空间复杂度O(1)。其中h为树的高度 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00191">191</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<a class="anchor" id="a2dfe32f3914b03ccdb22f88f24a6afdd"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::shared_ptr&lt;<a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a>&gt; <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::max </td>
          <td>(</td>
          <td class="paramtype">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td>
          <td class="paramname"><em>node</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>max:在二叉搜索树中最大值的节点。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">node:从指定节点开始搜索（默认为树的根节点）</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>: 二叉树种的最大节点的强引用</dd></dl>
<p>在二叉搜索树中搜索最小值的节点。其中可以指定从哪个节点开始搜索。若不指定搜索节点，则默认为树的根节点</p>
<p>算法：由于二叉树的性质，搜索最大值很简单。从指定节点沿着右子节点一路向下遍历，最右下方的节点即为最小值节点</p>
<p>算法时间复杂度O(h)，空间复杂度O(1)。其中h为树的高度 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00099">99</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<a class="anchor" id="af0bb418896808f72bb1edee55d238d55"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::shared_ptr&lt;<a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a>&gt; <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::min </td>
          <td>(</td>
          <td class="paramtype">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td>
          <td class="paramname"><em>node</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>min:在二叉搜索树中最小值的节点。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">node:从指定节点开始搜索（默认为树的根节点）</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>: 二叉树种的最小节点的强引用</dd></dl>
<p>在二叉搜索树中搜索最小值的节点。其中可以指定从哪个节点开始搜索。若不指定搜索节点，则默认为树的根节点。</p>
<p>算法：由于二叉树的性质，搜索最小值很简单。从指定节点沿着左子节点一路向下遍历，最左下方的节点即为最小值节点</p>
<p>算法时间复杂度O(h)，空间复杂度O(1)。其中h为树的高度 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00075">75</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<a class="anchor" id="a0e767d97590d19c97d595708d4419fe1"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::shared_ptr&lt;<a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a>&gt; <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::predecesor </td>
          <td>(</td>
          <td class="paramtype">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td>
          <td class="paramname"><em>node</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>predecesor:二叉搜索树指定节点的前驱。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">node:要搜索前驱的节点</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>: 该节点的前驱节点的强引用或者空</dd></dl>
<p>给定二叉搜索树的某个节点，搜索其前驱节点。所谓的某节点<code>node</code>的前驱节点就是在二叉搜索树中，值小于<code>node</code>的所有节点中最大的那一个。</p>
<p>一个节点<code>node</code>的前驱有以下情况：</p>
<ul>
<li>如果<code>node</code>有左子节点，则以左子节点为根的子树中的最大值节点就是<code>node</code>的前驱节点</li>
<li>如果<code>node</code>没有左子节点，则查看父节点<ul>
<li>若<code>node</code>是父节点的右子节点；则<code>node</code>的前驱节点是<code>node</code>的父节点</li>
<li>若<code>node</code>是父节点的左子节点；则<code>node</code>设置为<code>node-&gt;parent</code>，递归向直到<code>node</code>是它父亲的右子节点；此时<code>node</code>的前驱节点是<code>node</code>的父节点</li>
</ul>
</li>
</ul>
<p>算法时间复杂度O(h)，空间复杂度O(1)。其中h为树的高度 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00161">161</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<a class="anchor" id="a3b59a0c117766590f7f01027ad0fbfff"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::remove </td>
          <td>(</td>
          <td class="paramtype">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td>
          <td class="paramname"><em>node</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>remove:从二叉搜索树中删除节点。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">node:要删除的节点</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>: void</dd></dl>
<p>给定节点<code>node</code>，从二叉搜索树中删除它。如果<code>node</code>不在二叉搜索树中则抛出异常。</p>
<p>算法：</p>
<ul>
<li>如果<code>node</code>是一个叶子节点：则直接删除它</li>
<li>如果<code>node</code>有左子节点，但是没有右子节点：将左子剪切到<code>node</code>所在位置</li>
<li>如果<code>node</code>有右子节点，但是没有左子节点：将右子剪切到<code>node</code>所在位置</li>
<li>如果<code>node</code>既有左子节点，又有右子节点：首先获取<code>node</code>的后继节点<code>next_node</code><ul>
<li>如果<code>next_node</code>就是<code>node</code>的右子节点，则证明<code>next_node</code>没有左子（如果<code>next_node</code>有左子，则<code>node</code>的后继节点必然不是<code>next_node</code>）。 此时将<code>next_node</code>剪切到<code>node</code>所在位置，并且将<code>node</code>的左子挂载到<code>next_node</code>的左子</li>
<li>如果<code>next_node</code>不是<code>node</code>的右子节点，则<code>next_node</code>必然位于<code>node</code>右子为根的子树中。且<code>next_node</code>必然没有左子（否则<code>node</code>的后继节点必然不是<code>next_node</code>）<ul>
<li>把<code>next_node</code>的右子节点剪切到<code>next_node</code>的位置</li>
<li>将<code>next_node</code>剪切到<code>node</code>的右子位置</li>
<li>执行<code>next_node</code>就是<code>node</code>的右子节点的操作</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>算法时间复杂度O(h)，空间复杂度O(1)。其中h为树的高度 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00250">250</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<a class="anchor" id="affaf44d28dc2180f93669cb8d6c09c84"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::shared_ptr&lt;<a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a>&gt; <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::search </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html#a0a9b2de6326042f2a1fa8a3a0def67ab">T</a> &amp;&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td>
          <td class="paramname"><em>node</em> = <code>std::shared_ptr&lt;<a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a>&gt;()</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>search:在二叉搜索树中搜索指定内容的节点。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">value</td><td>搜索指定的内容 </td></tr>
    <tr><td class="paramname">node:从指定节点开始搜索（默认为树的根节点）</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>: 存储内容等于value的节点的强引用或者空</dd></dl>
<p>在二叉搜索树中搜索指定内容的节点。其中可以指定从哪个节点开始搜索。若不指定搜索节点，则默认为树的根节点.</p>
<p>算法时间复杂度O(h)，空间复杂度O(1)。其中h为树的高度 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00048">48</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<a class="anchor" id="a9d53e1f0b130263f2974dced515aa1f1"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename NodeType&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::shared_ptr&lt;<a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a>&gt; <a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">IntroductionToAlgorithm::TreeAlgorithm::SearchTree</a>&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;::successor </td>
          <td>(</td>
          <td class="paramtype">std::shared_ptr&lt; <a class="el" href="struct_introduction_to_algorithm_1_1_tree_algorithm_1_1_binary_tree.html#a9a441f3f41c5b69758204ba60fe02010">NodeType</a> &gt;&#160;</td>
          <td class="paramname"><em>node</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>successor:二叉搜索树指定节点的后继节点。 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">node:要搜索后继的节点</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>: 该节点的后继节点的强引用或者空</dd></dl>
<p>给定二叉搜索树的某个节点，搜索其后继节点。所谓的某节点<code>node</code>的后继节点就是在二叉搜索树中，值大于等于<code>node</code>的所有节点中最小的那一个（排除它自身）。</p>
<p>一个节点<code>node</code>的后继有以下情况：</p>
<ul>
<li>如果<code>node</code>有右子节点，则以右子节点为根的子树中的最小值节点就是<code>node</code>的后继节点</li>
<li>如果<code>node</code>没有右子节点，则查看父节点<ul>
<li>若<code>node</code>是父节点的左子节点；则<code>node</code>的后继节点是<code>node</code>的父节点</li>
<li>若<code>node</code>是父节点的右子节点；则<code>node</code>设置为<code>node-&gt;parent</code>，递归向直到<code>node</code>是它父亲的左子节点；此时<code>node</code>的后继节点是<code>node</code>的父节点</li>
</ul>
</li>
</ul>
<p>算法时间复杂度O(h)，空间复杂度O(1)。其中h为树的高度 </p>

<p>Definition at line <a class="el" href="searchtree_8h_source.html#l00127">127</a> of file <a class="el" href="searchtree_8h_source.html">searchtree.h</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>src/tree_algorithms/searchtree/<a class="el" href="searchtree_8h_source.html">searchtree.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="namespace_introduction_to_algorithm.html">IntroductionToAlgorithm</a></li><li class="navelem"><a class="el" href="namespace_introduction_to_algorithm_1_1_tree_algorithm.html">TreeAlgorithm</a></li><li class="navelem"><a class="el" href="class_introduction_to_algorithm_1_1_tree_algorithm_1_1_search_tree.html">SearchTree</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.10 </li>
  </ul>
</div>
</body>
</html>
